package org.halk.config;

import org.springframework.context.annotation.Bean;
   import org.springframework.context.annotation.Configuration;
   import org.thymeleaf.spring5.SpringTemplateEngine;
   import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
   import org.thymeleaf.spring5.view.ThymeleafViewResolver;

   @Configuration
   public class ThymeleafConfig {

       @Bean
       public SpringResourceTemplateResolver templateResolver() {
           SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
           templateResolver.setPrefix("classpath:/file/templates/");
           templateResolver.setSuffix(".html");
           templateResolver.setTemplateMode("HTML");
           templateResolver.setCharacterEncoding("UTF-8");
           return templateResolver;
       }

       @Bean
       public SpringTemplateEngine templateEngine() {
           SpringTemplateEngine templateEngine = new SpringTemplateEngine();
           templateEngine.setTemplateResolver(templateResolver());
           return templateEngine;
       }

       @Bean
       public ThymeleafViewResolver viewResolver() {
           ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();
           viewResolver.setTemplateEngine(templateEngine());
           viewResolver.setCharacterEncoding("UTF-8");
           return viewResolver;
       }
   }
   